package top.xiangqifu.yuanshen.base;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import top.xiangqifu.yuanshen.entity.PageBean;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BasePageResult<T> extends BaseDataResult<T> {
    private PageBean page;

    public static <T> BasePageResult<T> ok(PageBean page, T data) {
        BasePageResult<T> result = new BasePageResult<>();
        result.buildInfo(SUCCESS_CODE, "", true);
        result.setData(data);
        result.setPage(page);
        return result;
    }

    public static <T> BasePageResult<T> failPage(String message) {
        BasePageResult<T> result = new BasePageResult<>();
        result.buildInfo(ERROR_CODE, message, false);
        return result;
    }
}
